home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / glibc108.gz / glibc108 / glibc-1.08.1 / sysdeps / m68k / fpu / switch / 68881-sw.h < prev    next >
C/C++ Source or Header  |  1992-05-24  |  3KB  |  65 lines

  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef    _68881_SWITCH_H
  20.  
  21. #define    _68881_SWITCH_H    1
  22. #include <sys/cdefs.h>
  23.  
  24. /* This is the format of the data at the code label for a function which
  25.    wants to switch depending on whether or not a 68881 is present.
  26.  
  27.    Initially, `insn' is a `jsr' instruction, and `target' is __68881_switch.
  28.    The first time such a function is called, __68881_switch determines whether
  29.    or not a 68881 is present, and modifies the function accordingly.
  30.    Then `insn' is a `jmp' instruction, and `target' is the value of `fpu'
  31.    if there is 68881, or the value of `soft' if not.  */
  32.  
  33. struct switch_caller
  34.   {
  35.     unsigned short int insn;    /* The `jsr' or `jmp' instruction.  */
  36.     __ptr_t target;        /* The target of the instruction.  */
  37.     __ptr_t soft;        /* The address of the soft function.  */
  38.     __ptr_t fpu;        /* The address of the 68881 function.  */
  39.   };
  40.  
  41. /* These are opcodes (values for `insn', above) for `jmp' and `jsr'
  42.    instructions, respectively, to 32-bit absolute addresses.  */
  43. #define    JMP    0x4ef9
  44. #define    JSR    0x4eb9
  45.  
  46.  
  47. /* Function to determine whether or not a 68881 is available,
  48.    and modify its caller (which must be a `struct switch_caller', above,
  49.    in data space) to use the appropriate version.  */
  50. extern void EXFUN(__68881_switch, (int __dummy));
  51.  
  52.  
  53. /* Define FUNCTION as a `struct switch_caller' which will call
  54.    `__FUNCTION_68881' if a 68881 is present, and `__FUNCTION_soft' if not.
  55. #define    switching_function(FUNCTION)                           \
  56.   struct switch_caller FUNCTION =                          \
  57.     {                                          \
  58.       JSR, (__ptr_t) __68881_switch,                          \
  59.       __CONCAT(__CONCAT(__,FUNCTION),_soft),                      \
  60.       __CONCAT(__CONCAT(__,FUNCTION),_68881)                      \
  61.     }
  62.  
  63.  
  64. #endif    /* 68881-switch.h  */
  65.